/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gebze.Util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Win7
 */
public class GbzTerminal extends Thread {

    private Map map;

    public GbzTerminal(Map<String, GbzScannerClientHandler> sockets) {
        map = sockets;
    }

    @Override
    public void run() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while (true) {
            String text = null;
            try {
                text = br.readLine();
                GbzScannerClientHandler clientHandler = (GbzScannerClientHandler) map.get(text);
                if (clientHandler != null) {
                    clientHandler.getOut().write("dosya göndermelisin...\n");
                    clientHandler.getOut().flush();
                }
            } catch (IOException ex) {
                Logger.getLogger(GbzTerminal.class.getName()).log(Level.SEVERE, null, ex);
            }
            System.out.println(map.size() + text);
        }
    }
}
